/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.pojo.sqlServer;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
* @website https://eladmin.vip
* @description /
* @author xinglin
* @date 2024-08-14
**/
@Entity
@Data
@Table(name="pp_wms_task")
public class PPWmsTask implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "`logical_address_type`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "设备类型")
    private Integer logicalAddressType;

    @Column(name = "`wms_task_id`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "任务id")
    private String wmsTaskId;

    @Column(name = "`lpn_code`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "容器号")
    private String lpnCode;

    @Column(name = "`lpn_type`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "容器类型")
    private Integer lpnType;

    @Column(name = "`wcs_task_type`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "任务类型(1:入库任务    2:出库任务)")
    private Integer wcsTaskType;

    @Column(name = "`warehouse_code`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "仓库编码(RTL，PP)")
    private String warehouseCode;

    @Column(name = "`aisle`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "巷道号")
    private Integer aisle;

    @Column(name = "`from_location`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "取货货位")
    private String fromLocation;

    @Column(name = "`to_location`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "放货货位")
    private String toLocation;

    @Column(name = "`level`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "优先级")
    private Integer level;

    @Column(name = "`status`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "任务状态")
    //0-正常 1-取消(WCS已执行的任务不允许取消)
    private Integer status;

    @Column(name = "`description`")
    @ApiModelProperty(value = "任务描述")
    private String description;

    @Column(name = "`created`")
    @ApiModelProperty(value = "任务创建时间")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime created;

    public void copy(PPWmsTask source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
